import React, {
  Component,
  TouchableOpacity,
  View,
  Text
} from 'react-native';
import BarcodeScanner from 'react-native-barcodescanner';

class BarcodeScannerpage extends Component {
  constructor(props) {
    super(props);

    this.state = {
      torchMode: 'off',
      cameraType: 'back',
       navigator :this.props.navigator,
    
    };
  }

  barcodeReceived(e) {
    // console.log('Barcode: ' + e.data);
    // console.log('Type: ' + e.type);
     alert('Barcode: ' + e.data);
    //  alert('Type: ' + e.type);
   
   // this.props.navigator.replace({
   //              name: 'deviceCreate',
   //              component: deviceCreate,
   //             params:{
   //              date:e.data,
   //             }
   //          })

  }
    
  render() {


    return (
      //   <View>
      // <TouchableOpacity onPress={()=>this.turnFlash.bind(this)}>

 
      //   <View>
      //     <Text>闪光灯</Text>
      //   </View>
      // </TouchableOpacity>
       


      <BarcodeScanner
        onBarCodeRead={this.barcodeReceived.bind(this)}
        style={{ flex: 1 }}
        torchMode={this.state.torchMode}
        cameraType={this.state.cameraType}
      >
      </BarcodeScanner>
      
     
        
      
    );
       

      

  }
}
export default BarcodeScannerpage